Programs That Feature Selection

⏱️ Do It Now

Copy the title below into OneNote

Lesson 4 - Spring 2 - Selection




⌨️ Setting Up For Today

Click this link: VSCODEEDU.COM


  • Sign In with your Microsoft Account
  • Create a New project and call it Y8 - SP2.4 - Selection
  • Rename main.py as Activity 1.py


Copy the table below into OneNote

Share your project and paste the link into the table

📝 Link To My Project

Paste a link to your project Python Lesson SP2.4 below:



🎯 Learning Objectives


  • LO1: We will learn how to work with selection
  • LO2: We will combine inputs, variables and selection in order to produce a quiz

🐍 Coding Activity 1

Copy and paste this comment above the activity you are about to complete
# 🐍 Activity 1 - Making A Quiz


Instruction set......

  • You will create a quiz on a topic of your choice
  • Each question will need a separate variable
  • Make sure you use the .lower() function properly


The program should output something like this

What is the capital of Japan? Tokyo
Correct, the capital of Japan is Tokyo

Name a primary colour: blue
Correct, blue is a primary colour

How old is TGGS? 20
Incorrect, TGGS is 101


Code Help

(1) Asking the user to input text and assign it to a variable

flavour = input("Name your favourite flavour of ice cream:")

(2) Using selection to assess a user response

if q1.lower() == "exeter":
    print("Correct")
else:
    print("Incorrect")

(3) Using branching selection (ELIF) for more than one correct answer

if colour.lower() == "red":
    print("Correct")
elif colour.lower() == "yellow":
    print("Correct")
elif colour.lower() == "blue":
    print("Correct")
else:
    print("Incorrect")

⌨️ Extension

Create a new file called Extension.py

Copy and paste this comment above the activity you are about to complete
# Extension - Interactive Story


Instruction set......

  • You will create a story where the user is involved
  • There will be different outcomes for each part, depending on what the user types

This is some starter code for you...

print("Welcome brave adventurer")
playername = input("Enter your name: ")

print(f"{playername}, we are about to embark upon a quest")

print("Decide upon your role in the game")
role = input("(1) Sorcerer   (2) Warrior   (3) Archer: ")

if role == "1":
    print("You are a sorcerer, powerful enough to defeat the enemy with magic and spells")
    type = "sorcerer"
elif role == "2":
    print("You are a warrior, and as such you can defeat multiple enemies with one strike of your sword.")
    type = "warrior"
elif role == "3":
    print("You are a archer, you are able to defend your travelling party from a distance, and ward off intruders.")
    type = "archer"
else:
    print("You made an invalid choice")


You must continue the story!!!

Suggested next stage
print("You leave the village and begin your journey.")

print("After walking for many miles, you arrive at the edge of a dark forest.")
print("The trees are tall and the path ahead is quiet.")

print("Suddenly, you hear a strange noise in the bushes.")

choice = input("(1) Investigate the noise   (2) Keep walking: ")

if choice == "1":
    print("You carefully move towards the bushes.")
    print("A small goblin jumps out and stares at you!")

elif choice == "2":
    print("You decide it is safer to keep walking.")
    print("As you move further along the path, the forest becomes darker.")

else:
    print("You stand still, unsure of what to do.")

Code Help

(1) Asking the user to input text, before outputting their response

flavour = input("Name your favourite flavour of ice cream:")
print(f"Wow, {flavour} is definitely the best!")

(2) Using selection to assess a user response

if q1.lower() == "exeter":
    print("Correct")
else:
    print("Incorrect")

(3) Using branching selection (ELIF) for more than one correct answer

if colour.lower() == "red":
    print("Correct")
elif colour.lower() == "yellow":
    print("Correct")
elif colour.lower() == "blue":
    print("Correct")
else:
    print("Incorrect")

📝 Mini Whiteboard Task

📝 MWB Reflection Task

Open the mini-whiteboard app in a new tab

Your teacher will start with these leading questions:

  • What term describes the use of IF and ELSE?
  • If there is more than one correct answer, what must you do?